<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>增加页面</title>
<%
	String bathPath = request.getContextPath();
	pageContext.setAttribute("bathPath", bathPath);
%>

  <link rel="stylesheet" href="${bathPath}/frame/layui/css/layui.css"  media="all">
  <script type="text/javascript" src="${bathPath}/js/jquery-1.9.1.min.js" ></script>
<script type="text/javascript" src="${bathPath}/js/ajaxSessionOut.js" ></script>
<!-- layer -->
<link type="text/css" rel="stylesheet" href="${bathPath}/js/layer/skin/layer.css"/>
<script type="text/javascript" src="${bathPath}/js/layer/layer.js" ></script>
<script src="${bathPath}/frame/layui/layui.js" charset="utf-8"></script>

<!-- layer -->
<link type="text/css" rel="stylesheet" href="${bathPath}/js/layer/skin/layer.css"/>
<link type="text/css" rel="stylesheet" href="${bathPath}/js/layer/layer.js"/>
<script type="text/javascript">
layui.use(['form', 'layedit', 'laydate','upload'], function(){
    var form = layui.form
            ,layer = layui.layer
            ,layedit = layui.layedit
            ,laydate = layui.laydate
            ,upload = layui.upload;

    //日期
    laydate.render({
        elem: '#birthday'
    });
    laydate.render({
        elem: '#birthday'
    });
    laydate.render({
        elem: '#eddate'
    });
    laydate.render({
        elem: '#eddate'
    });
    laydate.render({
        elem: '#cardvaliddate'
    });
    laydate.render({
        elem: '#cardvaliddate'
    });
    
     var uploadInst = upload.render({
        elem: '#test1'
        ,method:'post'
        ,url: '${bathPath}/file/uploadOneImageAjax.action'
/*         ,auto:false
        ,bindAction:'#bao' */
        ,before: function(obj){
          //预读本地文件示例，不支持ie8
           this.data={'userid':$('#userid').val()};//关键代码
          obj.preview(function(index, file, result){
            $('#demo1').attr('src', result); //图片链接（base64）
          });
        }
        ,done: function(res){
          //如果上传失败
          if(res.code > 0){
            return layer.msg('上传失败');
          }
          //上传成功
        }
        ,error: function(){
          //演示失败状态，并实现重传
          var demoText = $('#demoText');
          demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
          demoText.find('.demo-reload').on('click', function(){
            uploadInst.upload();
          });
        }
      }); 

});
function search(){
	var uId=document.getElementById("userid").value;
	var cType=document.getElementById("cardtype").value;
	if(uId=="" ||uId==null){
		top.layer.msg("人员编号不能为空");
	}else if(cType=="" || cType==null){
		top.layer.msg("权限类别不能为空");
	}else{
		var param=$("form").serialize();
		//layer.confirm("保存成功", {btn: ['确定'], title: "提示"}, function(){
			$.ajax({
				 type:"POST",
				 async:false,
				 dataType:"text",
				 data:param,
			     url:"${bathPath}/aDKUserInfo/insertUserInfo.action",
			     success:function(data){
			    	/*if(data!="SUCCESS"){layer.msg(data);} */
			    	 layer.confirm("保存成功！", {btn: ['确定'], title: "提示",skin:"my-skin"}, function(){
			    		// layer.close(layer.index);
			    		// parent.location.reload();
			    		parent.layer.close(parent.layer.index);
						parent.location.reload();
			    	});
			     }
			 });
			parent.layer.close(parent.layer.index);
	}
}
$(function(){
	
	//验证名称唯一性
	$("#userid").blur(
		function(){
			var userid = document.getElementById('userid').value;
			//alert("进入keyup");
			$.ajax({
				type:"POST",
				async:true,
				url:"${bathPath}/aDKUserInfo/checkSname.action",
				data : {"userid":userid},
				success:function(data){
						if(data!=0){
							top.layer.msg("人员编号已存在");
						}
					}
				});
	});
	
	
	$.ajax({
		 type:"POST",
		 async:false,
		 data:"",
	     url:"${bathPath}/aDKUserInfo/selectDpetName.action",
	     success:function(msg){
	    	var html="";
	    	html+="<option value=''>"+'请选择'+"</option>";
	    	for (var i = 0; i < msg.length; i++) {
			    html+="<option value='"+msg[i].depId+"'>"+msg[i].depName+"</option>";
			}
	    	$("#depid").html(html);
	     }
	 });
	
	//所属组织机构下拉框回填
	$("#depid").val("${u.depid}");
});


</script>
<style type="text/css">
	img {
		margin-left: 10px;
		width: 20px;
		height: 20px;
	}
	
	
	}
</style></head>
<body >
	
	<div id="tt" class="easyui-panel" style="width:965px;height:455px;">
	
<div class="first_div" style="border-right:none;border-bottom:none;border-left:none;">

	<form class="layui-form layui-form-pane" action="" method="post" enctype="multipart/form-data">
	<input type="hidden" name="autoid" value="${u.autoid}" />
	<div>
	<div class="layui-inline">
	     <div class="layui-form-item" style="margin-left:15px; margin-top: 15px;">
	     <div class="layui-inline">
	    	<label class="layui-form-label"  style="width: 160px;">人员编号</label>
		   	<div class="layui-input-block" style="width: 150px;margin-left:160px;" >
		   		<input type="text" id="userid" name="userid" lay-verify="required" style="width:190px;" placeholder="请输入" class="layui-input"  value="${u.userid}" />
		    </div>
		 </div>
		 <div class="layui-inline" style="margin-left: 50px;">
	     	<label class="layui-form-label"  style="width: 160px;">名称</label>
		    <div class="layui-input-block" style="width: 150px;margin-left:160px;" >
		    	<input type="text" id="username" name="username" lay-verify="required" placeholder="请输入" style="width: 190px;"class="layui-input"  value="${u.username}" />
		    </div>
		 </div>
  	</div>
  
  
    <div class="layui-form-item" style="margin-left: 15px;margin-top: -12px;">
    <div class="layui-inline">
        <label class="layui-form-label" style="width: 160px;">部门</label>
        <div class="layui-input-inline">
      <select type="text" id="depid" name="depid" lay-verify="required"  autocomplete="off" class="layui-input">
      </select>
        </div>
    </div>
     <div class="layui-inline">
    <label class="layui-form-label"  style="width: 160px;">标识号</label>
	   <div class="layui-input-block" style="width: 150px;margin-left:160px;" >
	      <input type="text" id="flag" name="flag" lay-verify="required" placeholder="请输入" style="width: 190px;"
                   class="layui-input"  value="${u.flag}" />
	    </div>
	    </div>
    </div>
   
   <div class="layui-form-item" style="margin-left: 15px;margin-top: -12px;">
     <div class="layui-inline">
        <label class="layui-form-label" style="width: 160px;">是否考勤</label>
        <div class="layui-input-inline">
            <select name="kaoqin" lay-filter="aihao">
        <option value="${u.kaoqin}"></option>
        <option value="2" ${u.kaoqin=="2"?'selected':''}>不考勤</option>
        <option value="1" ${u.kaoqin=="1"?'selected':''}>考勤</option>
      </select>
        </div>
    </div>
     <div class="layui-inline">
    <label class="layui-form-label"  style="width: 160px;">密码</label>
	   <div class="layui-input-block" style="width: 150px;margin-left:160px;" >
	      <input type="text" id="password" name="password" lay-verify="required" placeholder="请输入"  style="width: 190px;"
                   class="layui-input" value="${u.password}" / >
	    </div>
	    </div>
    </div>
    
    
    <div class="layui-form-item" style="margin-left: 15px;margin-top: -12px;">
     <div class="layui-inline">
        <label class="layui-form-label" style="width: 160px;">证件类型</label>
        <div class="layui-input-inline">
            <select name="certtype" lay-filter="aihao">
        <option value="${u.certtype}"></option>
        <option value="2" ${u.certtype=="2"?'selected':''}>身份证</option>
        <option value="1"  ${u.certtype=="1"?'selected':''}>护照</option>
      </select>
        </div>
    </div>
     <div class="layui-inline">
    <label class="layui-form-label"  style="width: 160px;">证件号码</label>
	   <div class="layui-input-block" style="width: 150px;margin-left:160px;" >
	      <input type="text" id="certnum" name="certnum" lay-verify="required" placeholder="请输入"  style="width: 190px;"
                   class="layui-input" value="${u.certnum}" / >
	    </div>
	    </div>
    </div>
    
    
     <div class="layui-form-item" style="margin-left: 15px;margin-top: -12px;">
     <div class="layui-inline">
        <label class="layui-form-label" style="width: 160px;">性别</label>
        <div class="layui-input-inline">
            <select name="sex" lay-filter="aihao">
        <option value="${u.sex}"></option>
        <option ${u.sex == '2' ? "selected='selected'" : ""} value="2" >男</option>
        <option ${u.sex == '1' ? "selected='selected'" : ""} value="1" >女</option>
      </select>
        </div>
    </div>
     <div class="layui-inline">
    <label class="layui-form-label"  style="width: 160px;">出生日期</label>
	   <div class="layui-input-block" style="width: 150px;margin-left:160px;" >
	      <input type="text" id="birthday" name="birthday" autocomplete="off" class="layui-input" placeholder="请输入" value="${u.birthday}" /  style="width: 190px;">
	    </div>
	    </div>
    </div>
    </div>
   <div class="layui-inline" style="margin-left: 30px;margin-top: 15px;">
    <div class="layui-upload">
  <div class="layui-upload-list">
    <img class="layui-upload-img" id="demo1" style="width:200px; height: 180px;" src="${u.photo}">
    <p id="demoText"></p> 
  </div>
   <button type="button" class="layui-btn" id="test1" style="margin-left: 10px;">上传图片</button> 
</div>
    </div> 
    </div>
    
    
    <div class="layui-form-item" style="margin-left: 15px;margin-top: -12px;">
     <div class="layui-inline">
        <label class="layui-form-label" style="width: 160px;">民族</label>
        <div class="layui-input-inline">
            <select name="nation" lay-filter="aihao">
        <option value="${u.nation}"></option>
        <option value="汉" ${u.nation=="汉"?'selected':''}>汉</option>
        <option value="满" ${u.nation=="满"?'selected':''}>满</option>
      </select>
        </div>
    </div>
     <div class="layui-inline">
    <label class="layui-form-label"  style="width: 160px;">人员类型</label>
	  <div class="layui-input-inline">
            <select name="usertype" lay-filter="aihao">
        <option value="${u.usertype}"></option>
        <option value="2" ${u.usertype=="2"?'selected':''}>员工</option>
        <option value="1" ${u.usertype=="1"?'selected':''}>经理</option>
      </select>
        </div>
	    </div>
    </div>
    
    <div class="layui-form-item" style="margin-left: 15px;margin-top: -12px;">
     <div class="layui-inline">
       <label class="layui-form-label"  style="width: 160px;">入职日期</label>
	   <div class="layui-input-block" style="width: 150px;margin-left:160px;" >
	      <input type="text" id="eddate" name="eddate" autocomplete="off" class="layui-input"  style="width: 190px;" placeholder="请输入" value="${u.eddate}" />
	    </div>
    </div>
     <div class="layui-inline " style="margin-left: 50px;">
     <label class="layui-form-label"  style="width: 160px;">联系电话</label>
	   <div class="layui-input-block" style="width: 150px;margin-left:160px;" >
	      <input type="text" id="telno" name="telno" lay-verify="required" placeholder="请输入"  style="width: 190px;"
                   class="layui-input"  value="${u.telno}" />
	    </div>
	    </div>
	   <%--  <div class="layui-inline " style="margin-left: 50px;">
     <label class="layui-form-label"  style="width: 160px;">住址</label>
	   <div class="layui-input-block" style="width: 150px;margin-left:160px;" >
	      <input type="text" id="address" name="address" lay-verify="required" placeholder="请输入"  style="width: 190px;"
                   class="layui-input"  value="${u.address}" />
	    </div>
	    </div> --%>
    </div>
    
    <div class="layui-form-item" style="margin-left: 15px;margin-top: -12px;">
     <div class="layui-inline">
        <label class="layui-form-label" style="width: 160px;">权限类别</label>
        <div class="layui-input-inline">
            <select name="cardtype" id="cardtype" lay-filter="aihao">
        <option value="${u.cardtype}"></option>
        <option value="3" ${u.cardtype=="3"?'selected':''}>A类</option>
        <option value="1" ${u.cardtype=="1"?'selected':''}>B类</option>
        <option value="2" ${u.cardtype=="2"?'selected':''}>C类</option>
      </select>
        </div>
    </div>
     <div class="layui-inline">
    <label class="layui-form-label"  style="width: 160px;">卡有效期</label>
	   <div class="layui-input-block" style="width: 150px;margin-left:160px;" >
	      <input type="text" id="cardvaliddate" name="cardvaliddate" autocomplete="off" class="layui-input"  placeholder="请输入" value="${u.cardvaliddate}"  style="width: 190px;">
	    </div>
	    </div>
	    <%-- <div class="layui-inline " style="margin-left: 50px;">
     <label class="layui-form-label"  style="width: 160px;">备注</label>
	   <div class="layui-input-block" style="width: 150px;margin-left:160px;" >
	      <input type="text" id="remark" name="remark" lay-verify="required" placeholder="请输入"  style="width: 190px;"
                   class="layui-input"  value="${u.remark}" />
	    </div>
	    </div> --%>
    </div>
     <div class="layui-form-item" style="margin-top: -12px;">
     <div class="layui-inline " style="margin-left: 15px;">
     <label class="layui-form-label"  style="width: 160px;">住址</label>
	   <div class="layui-input-block" style="width: 150px;margin-left:160px;" >
	      <input type="text" id="address" name="address" lay-verify="required" placeholder="请输入"  style="width: 563px;"
                   class="layui-input"  value="${u.address}" />
	    </div>
	    </div>
	    </div>
	    
	    <div class="layui-form-item" style="margin-top: -12px;">
     <div class="layui-inline " style="margin-left: 15px;">
     <label class="layui-form-label"  style="width: 160px;">备注</label>
	   <div class="layui-input-block" style="width: 150px;margin-left:160px;" >
	      <input type="text" id="remark" name="remark" lay-verify="required" placeholder="请输入"  style="width: 565px;"
                   class="layui-input"  value="${u.remark}" />
	    </div>
	    </div>
	    </div>
</form>
	 <div class="layui-form-item">
        <button class="layui-btn" lay-submit="" id="bao"  lay-filter="sub" style="margin-left:850px;margin-top:-20px;" onclick="search()">保存</button>
    </div>
	<div style="margin:3px 10px 10px 10px;"></div>
	
	<table id="dg"></table>
	</div>
	</div>
</body>
</html>